/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import vo.VOCountry;

/**
 *
 * @author santiagobaldrich
 */
@Entity
@Table(name = "Country")
@NamedQueries(
{
    @NamedQuery(name = "Country.findAll", query = "SELECT c FROM Country c"),
    @NamedQuery(name = "Country.findByIdCountry", query = "SELECT c FROM Country c WHERE c.idCountry = :idCountry"),
    @NamedQuery(name = "Country.findByName", query = "SELECT c FROM Country c WHERE c.name = :name")
})
public class Country implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idCountry")
    private Integer idCountry;
    @Basic(optional = false)
    @Column(name = "name")
    private String name;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "country")
    private Collection<Institution> institutionCollection;

    public Country()
    {
    }

    public Country(Integer idCountry)
    {
        this.idCountry = idCountry;
    }

    public Country(Integer idCountry, String name)
    {
        this.idCountry = idCountry;
        this.name = name;
    }

    public Integer getIdCountry()
    {
        return idCountry;
    }

    public void setIdCountry(Integer idCountry)
    {
        this.idCountry = idCountry;
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public Collection<Institution> getInstitutionCollection()
    {
        return institutionCollection;
    }

    public void setInstitutionCollection(Collection<Institution> institutionCollection)
    {
        this.institutionCollection = institutionCollection;
    }

    @Override
    public int hashCode()
    {
        int hash = 0;
        hash += (idCountry != null ? idCountry.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Country))
        {
            return false;
        }
        Country other = (Country) object;
        if ((this.idCountry == null && other.idCountry != null) || (this.idCountry != null && !this.idCountry.equals(other.idCountry)))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        return "entities.Country[idCountry=" + idCountry + "]";
    }
    public VOCountry getVO()
    {
        VOCountry vo = new VOCountry();
        vo.setIdCountry(idCountry);
        vo.setName(name);
        return vo;
    }

}
